import request from "@/utils/request";

enum Api {
  addReferenceUrl = "/api/ipo/refdata/v1",
  //昨天的数据
  addhomelist = "/api/ipos/listv2",
  //今天的数据
  addhomelist1 = "/api/ipos/listv1",

  offeringsUrl="/api/ipo/refdata/offering",
  EventData="/api/ipos/listingData",
  TypeofList="/api/ipo/refdata/typeOfListing",
  searchUrl="/api/ipo/refdata/search",
  selectUrl="/api/ipo/refdata/searchAndFilter",
  findAllListingDate="/api/ipo/refdata/findAllListingDate",
  versionNumber = "/version/versionNumber",
  getIPAddress = "/Statistics/getIPAddress",
  uv = "/Statistics/uv",
  pv = "/Statistics/pv"
}
//获取ipo详情页的数据
export const getIpo = (ipoID:string) => {
  return request.get<any, null>(Api.addReferenceUrl+`?ipoID=${ipoID}`);
};
//listv1
export const getHomeIpo = () => {
  return request.get<any, null>(Api.addhomelist1);
};
//获取ipo的offerings数据
export const getOfferings = (ipoID:string) => {
  return request.get<any, null>(Api.offeringsUrl+`?ipoID=${ipoID}`);
};
//获取首页的getEventData数据
export const getEventData = (dateString:string) => {
  return request.get<any, null>(Api.EventData+`?dateString=${dateString}`);
};
//获取ipo的typeofListing数据
export const getTypeofListing = (ipoID:string) => {
  return request.get<any, null>(Api.TypeofList+`?ipoID=${ipoID}`);
};
//获取首页的搜索数据
export const getSearchListing = (keyWord:string) => {
  // return request.post<any, null>(Api.selectUrl+`?keyWord=${keyWord}`);

  return request.post<any, null>(Api.selectUrl,{keyWord});
}
export const getDate = () => {
  return request.get<any, null>(Api.findAllListingDate);
};
//
export const getVersion = () => {
  return request.get<any, null>(Api.versionNumber);
};
export const getIPAddress = () => {
  return request.post<any, null>(Api.getIPAddress);
};
export const postuv = (data: any) => {
  return request.post<any, null>(Api.uv,{data});
};
export const postpv = (data: any) => {
  
  return request.post<any, null>(Api.pv,{data});
};
type selectObj={
  status?:string|string[]
  tradeCurrency?:string|string[]
  offerType?:string|string[]
  listSecurities?:string|string[]
  IPOs?:string|string[]
  listPlatform?:string|string[]
  
}


export const getSelectList = (body:selectObj) => {
  const status=body.status;
  return request.post<any, null>(Api.selectUrl,body);
};
